package com.iwdnb.gkgz.common.model.dto;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import com.iwdnb.gkgz.common.utils.TulongdaoUtils;
import lombok.Data;

/**
 * 屠龙刀价格匹配信息
 */
@Data
public class TldMatchInfo {

    private String code;

    private List<TldMatchItem> openMatchItems;

    private List<TldMatchItem> matchItems;

    private List<TldMatchItem> crossItems;

    private TldMatchItem matchItem;

    private Integer index;

    private String matchDate;

    private TldSellInfo sellInfo;

    private BigDecimal openPrice;
    /**
     * 图形编码
     */
    private String stockImageCode;
    /**
     * 图形收益类型
     */
    private String stockImageProfitType;

    private StockDayData data;

    /**
     * 预警标识
     */
    private String earlyWarnFlag;
    /**
     * 策略评分
     */
    private BigDecimal score;


    @Data
    public static class TldMatchItem {

        private Integer period;

        private BigDecimal price;

        private BigDecimal avg;

        private BigDecimal rate;

        private BigDecimal buyPrice;

        private boolean ignore;

        /**
         * 是否开盘命中
         */
        private String openMatchFlag;

    }

    @Data
    public static class TldSellInfo {

        private Date sellTime;

        private BigDecimal sellPrice;

        private String sellRemark;

        private String sellType;

    }

    public boolean isMatch() {
        return Objects.nonNull(TulongdaoUtils.getMatchItem(openMatchItems, matchItems, crossItems, openPrice));
    }

}
